package com.zz.ecommerce.assistSysManage.eBilling;

import com.zz.ecommerce.assistSysManage.eBilling.bean.*;
import com.zz.ecommerce.common.CommonDao;
import com.zz.ecommerce.common.GridRequest;
import com.zz.ecommerce.common.GridResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 电子账册controller
 */
@Controller
@RequestMapping("/eBilling")
public class TElectronicBillingController {
    @Autowired
    CommonDao commonDao;

    /**
     * 电子账册列表页
     *
     * @return
     */
    @RequestMapping(value = "/tElectronicBillingManager", method = RequestMethod.GET)
    public String TElectronicBillingManager() {
        return "assistSysManager/eBilling/telectronicbilling_manager";
    }

    /**
     * 电子账册列表查询
     *
     * @param gridRequest
     * @param tElectronicBilling
     * @return
     */
    @RequestMapping(value = "/qryTElectronicBillingPage", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public GridResult<TElectronicBilling> qryTElectronicBillingPage(GridRequest gridRequest, TElectronicBilling tElectronicBilling) {
        List<TElectronicBilling> list = commonDao.pageWhere("T_ELECTRONIC_BILLING", tElectronicBilling, gridRequest.getStart(), gridRequest.getEnd(), "", "");
        long count = commonDao.countWhere("T_ELECTRONIC_BILLING", tElectronicBilling, "");
        return new GridResult<TElectronicBilling>(list, gridRequest, count);
    }

    /**
     * 保存电子账册列表
     *
     * @param session
     * @param tElectronicBilling
     * @return
     */
    @RequestMapping(value = "/saveTElectronicBilling", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String saveTElectronicBilling(HttpSession session, TElectronicBilling tElectronicBilling) {
        return "success";
    }

    /**
     * 电子账册详情
     *
     * @param tElectronicBilling
     * @param modelMap
     * @return
     */
    @RequestMapping(value = "/getTElectronicBillingDetail", method = {RequestMethod.GET, RequestMethod.POST})
    public String getTElectronicBillingDetail(TElectronicBilling tElectronicBilling, ModelMap modelMap) {
        TElectronicBilling tElectronicBillingDetail = (TElectronicBilling) commonDao.qryOneCommon("T_ELECTRONIC_BILLING", tElectronicBilling, "");
        modelMap.put("tElectronicBilling", tElectronicBillingDetail);
        return "assistSysManager/eBilling/telectronicbilling_detail";
    }

    @RequestMapping(value = "tEBillingConsumptionManager", method = RequestMethod.GET)
    public String TEBillingConsumptionManager() {
        return "assistSysManager/eBilling/tebillingconsumption_manager";
    }

    @RequestMapping(value = "qryTEBillingConsumptionPage", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public GridResult<TEBillingConsumption> qryTEBillingConsumptionPage(GridRequest gridRequest, TEBillingConsumption tEBillingConsumption) {
        List<TEBillingConsumption> list = commonDao.pageWhere("T_E_BILLING_CONSUMPTION", tEBillingConsumption, gridRequest.getStart(), gridRequest.getEnd(), "", "");
        long count = commonDao.countWhere("T_E_BILLING_CONSUMPTION", tEBillingConsumption, "");
        return new GridResult<TEBillingConsumption>(list, gridRequest, count);
    }

    @RequestMapping(value = "saveTEBillingConsumption", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String saveTEBillingConsumption(HttpSession session, TEBillingConsumption tEBillingConsumption) {
        return "success";
    }

    @RequestMapping(value = "getTEBillingConsumptionDetail", method = {RequestMethod.GET, RequestMethod.POST})
    public String getTEBillingConsumptionDetail(TEBillingConsumption tEBillingConsumption, ModelMap modelMap) {
        TEBillingConsumption tEBillingConsumptionDetail = (TEBillingConsumption) commonDao.qryOneCommon("T_E_BILLING_CONSUMPTION", tEBillingConsumption, "");
        modelMap.put("tEBillingConsumption", tEBillingConsumptionDetail);
        return "assistSysManager/eBilling/tebillingconsumption_detail";
    }

    @RequestMapping(value = "tEBillingEndgoodManager", method = RequestMethod.GET)
    public String TEBillingEndgoodManager() {
        return "assistSysManager/eBilling/tebillingendgood_manager";
    }

    @RequestMapping(value = "qryTEBillingEndgoodPage", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public GridResult<TEBillingEndgood> qryTEBillingEndgoodPage(GridRequest gridRequest, TEBillingEndgood tEBillingEndgood) {
        List<TEBillingEndgood> list = commonDao.pageWhere("T_E_BILLING_ENDGOOD", tEBillingEndgood, gridRequest.getStart(), gridRequest.getEnd(), "", "");
        long count = commonDao.countWhere("T_E_BILLING_ENDGOOD", tEBillingEndgood, "");
        return new GridResult<TEBillingEndgood>(list, gridRequest, count);
    }

    @RequestMapping(value = "saveTEBillingEndgood", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String saveTEBillingEndgood(HttpSession session, TEBillingEndgood tEBillingEndgood) {
        return "success";
    }

    @RequestMapping(value = "getTEBillingEndgoodDetail", method = {RequestMethod.GET, RequestMethod.POST})
    public String getTEBillingEndgoodDetail(TEBillingEndgood tEBillingEndgood, ModelMap modelMap) {
        TEBillingEndgood tEBillingEndgoodDetail = (TEBillingEndgood) commonDao.qryOneCommon("T_E_BILLING_ENDGOOD", tEBillingEndgood, "");
        modelMap.put("tEBillingEndgood", tEBillingEndgoodDetail);
        return "assistSysManager/eBilling/tebillingendgood_detail";
    }

    @RequestMapping(value = "tEBillingEquipmentManager", method = RequestMethod.GET)
    public String TEBillingEquipmentManager() {
        return "assistSysManager/eBilling/tebillingequipment_manager";
    }

    @RequestMapping(value = "qryTEBillingEquipmentPage", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public GridResult<TEBillingEquipment> qryTEBillingEquipmentPage(GridRequest gridRequest, TEBillingEquipment tEBillingEquipment) {
        List<TEBillingEquipment> list = commonDao.pageWhere("T_E_BILLING_EQUIPMENT", tEBillingEquipment, gridRequest.getStart(), gridRequest.getEnd(), "", "");
        long count = commonDao.countWhere("T_E_BILLING_EQUIPMENT", tEBillingEquipment, "");
        return new GridResult<TEBillingEquipment>(list, gridRequest, count);
    }

    @RequestMapping(value = "saveTEBillingEquipment", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String saveTEBillingEquipment(HttpSession session, TEBillingEquipment tEBillingEquipment) {
        return "success";
    }

    @RequestMapping(value = "getTEBillingEquipmentDetail", method = {RequestMethod.GET, RequestMethod.POST})
    public String getTEBillingEquipmentDetail(TEBillingEquipment tEBillingEquipment, ModelMap modelMap) {
        TEBillingEquipment tEBillingEquipmentDetail = (TEBillingEquipment) commonDao.qryOneCommon("T_E_BILLING_EQUIPMENT", tEBillingEquipment, "");
        modelMap.put("tEBillingEquipment", tEBillingEquipmentDetail);
        return "assistSysManager/eBilling/tebillingequipment_detail";
    }

    @RequestMapping(value = "tEBillingMaterialsManager", method = RequestMethod.GET)
    public String TEBillingMaterialsManager() {
        return "assistSysManager/eBilling/tebillingmaterials_manager";
    }

    @RequestMapping(value = "qryTEBillingMaterialsPage", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public GridResult<TEBillingMaterials> qryTEBillingMaterialsPage(GridRequest gridRequest, TEBillingMaterials tEBillingMaterials) {
        List<TEBillingMaterials> list = commonDao.pageWhere("T_E_BILLING_MATERIALS", tEBillingMaterials, gridRequest.getStart(), gridRequest.getEnd(), "", "");
        long count = commonDao.countWhere("T_E_BILLING_MATERIALS", tEBillingMaterials, "");
        return new GridResult<TEBillingMaterials>(list, gridRequest, count);
    }

    @RequestMapping(value = "saveTEBillingMaterials", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String saveTEBillingMaterials(HttpSession session, TEBillingMaterials tEBillingMaterials) {
        return "success";
    }

    @RequestMapping(value = "getTEBillingMaterialsDetail", method = {RequestMethod.GET, RequestMethod.POST})
    public String getTEBillingMaterialsDetail(TEBillingMaterials tEBillingMaterials, ModelMap modelMap) {
        TEBillingMaterials tEBillingMaterialsDetail = (TEBillingMaterials) commonDao.qryOneCommon("T_E_BILLING_MATERIALS", tEBillingMaterials, "");
        modelMap.put("tEBillingMaterials", tEBillingMaterialsDetail);
        return "assistSysManager/eBilling/tebillingmaterials_detail";
    }
}
